package 补充数组;

public class 数组反转2 {
    public static void main(String[] args) {
        int[] a = new int[5];
        a[0] = (int) (Math.random() * 100);
        a[1] = (int) (Math.random() * 100);
        a[2] = (int) (Math.random() * 100);
        a[3] = (int) (Math.random() * 100);
        a[4] = (int) (Math.random() * 100);
        for (int i = 0; i < a.length; i++) {
            System.out.print(a[i] + "\t");
        }
        System.out.println('\n' + "*********************");


        int i, j, temp, l;
        l = a.length / 2;
        j = a.length - 1;
        for (i = 0; i < l; i++) {
            temp = a[i];
            a[i] = a[j];
            a[j] = temp;  //这三行将头尾相交换
            j--;

        }

        for (int k = 0; k < a.length; k++) {
            System.out.print(a[k] + "\t");
        }


    }
}